package cn.edu.lsu.integratedsurvey.bean.vo;

import cn.edu.lsu.integratedsurvey.bean.Student;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 * 学生数据返回VO对象
 *
 * @author Jasmine-drs
 * @date 2024/5/1 16:22
 */

@Data
public class StudentInfoVo {

	@NotNull(message = "[]不能为空")
	@ApiModelProperty("id索引")
	private Integer id;

	@NotBlank(message = "[姓名]不能为空")
	@Size(max = 20, message = "编码长度不能超过20")
	@ApiModelProperty("姓名")
	private String name;

	@NotBlank(message = "[学号]不能为空")
	@Size(max = 11, message = "编码长度不能超过11")
	@ApiModelProperty("学号")
	private String studentNumber;

	@Size(max = 255, message = "编码长度不能超过255")
	@ApiModelProperty("班级")
	private String grade;

	@Size(max = 255, message = "编码长度不能超过255")
	@ApiModelProperty("专业")
	private String profession;

	@NotNull(message = "[德育]不能为空")
	@ApiModelProperty("德育")
	private Double moral;

	@NotNull(message = "[智育]不能为空")
	@ApiModelProperty("智育")
	private Double intellectual;

	@NotNull(message = "[体育]不能为空")
	@ApiModelProperty("体育")
	private Double physical;

	@NotNull(message = "[美育]不能为空")
	@ApiModelProperty("美育")
	private Double aesthetic;

	@NotNull(message = "[劳动教育]不能为空")
	@ApiModelProperty("劳动教育")
	private Double labor;

	@NotNull(message = "[创新创业能力]不能为空")
	@ApiModelProperty("创新创业能力")
	private Double innovation;

	@NotNull(message = "[突出贡献]不能为空")
	@ApiModelProperty("突出贡献")
	private Double outstanding;

	@NotNull(message = "[操作员id]不能为空")
	@ApiModelProperty("操作员id")
	private Integer operatorId;

	@ApiModelProperty("总计")
	private Double sum;

	//	student对象转vo对象
	public static StudentInfoVo convertToVO(Student student) {
		if (student == null)
			return null;
		StudentInfoVo studentInfoVo = new StudentInfoVo();
		studentInfoVo.setId(student.getId());
		studentInfoVo.setName(student.getName());
		studentInfoVo.setStudentNumber(student.getStudentNumber());
		studentInfoVo.setGrade(student.getGrade());
		studentInfoVo.setProfession(student.getProfession());
		studentInfoVo.setMoral(student.getMoral());
		studentInfoVo.setIntellectual(student.getIntellectual());
		studentInfoVo.setPhysical(student.getPhysical());
		studentInfoVo.setAesthetic(student.getAesthetic());
		studentInfoVo.setLabor(student.getLabor());
		studentInfoVo.setInnovation(student.getInnovation());
		studentInfoVo.setOutstanding(student.getOutstanding());
		studentInfoVo.setOperatorId(student.getOperatorId());
		studentInfoVo.setSum(student.getMoral() +
				student.getIntellectual() +
				student.getPhysical() +
				student.getAesthetic() +
				student.getLabor() +
				student.getInnovation() +
				student.getOutstanding());
		return studentInfoVo;
	}
}
